package com.estebansm.apercuen.model.entities;

import java.sql.SQLException;

import oracle.jbo.JboException;
import oracle.jbo.Key;
import oracle.jbo.RowIterator;
import oracle.jbo.TxnValException;
import oracle.jbo.domain.DBSequence;
import oracle.jbo.domain.Date;
import oracle.jbo.domain.Number;
import oracle.jbo.server.AttributeDefImpl;
import oracle.jbo.server.EntityDefImpl;
import oracle.jbo.server.EntityImpl;
import oracle.jbo.server.SequenceImpl;
// ---------------------------------------------------------------------
// ---    File generated by Oracle ADF Business Components Design Time.
// ---    Wed Mar 06 12:22:24 ART 2013
// ---    Custom code may be added to this class.
// ---    Warning: Do not modify method signatures of generated methods.
// ---------------------------------------------------------------------
public class OrderEOImpl extends EntityImpl {
    private static EntityDefImpl mDefinitionObject;

    /**
     * AttributesEnum: generated enum for identifying attributes and accessors. Do not modify.
     */
    public enum AttributesEnum {
        OrderId {
            public Object get(OrderEOImpl obj) {
                return obj.getOrderId();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setOrderId((Number)value);
            }
        }
        ,
        OrderDate {
            public Object get(OrderEOImpl obj) {
                return obj.getOrderDate();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setOrderDate((Date)value);
            }
        }
        ,
        OrderShippedDate {
            public Object get(OrderEOImpl obj) {
                return obj.getOrderShippedDate();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setOrderShippedDate((Date)value);
            }
        }
        ,
        OrderStatusCode {
            public Object get(OrderEOImpl obj) {
                return obj.getOrderStatusCode();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setOrderStatusCode((String)value);
            }
        }
        ,
        OrderTotal {
            public Object get(OrderEOImpl obj) {
                return obj.getOrderTotal();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setOrderTotal((Number)value);
            }
        }
        ,
        CustomerId {
            public Object get(OrderEOImpl obj) {
                return obj.getCustomerId();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setCustomerId((Number)value);
            }
        }
        ,
        ShipToName {
            public Object get(OrderEOImpl obj) {
                return obj.getShipToName();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setShipToName((String)value);
            }
        }
        ,
        ShipToAddressId {
            public Object get(OrderEOImpl obj) {
                return obj.getShipToAddressId();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setShipToAddressId((Number)value);
            }
        }
        ,
        ShipToPhoneNumber {
            public Object get(OrderEOImpl obj) {
                return obj.getShipToPhoneNumber();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setShipToPhoneNumber((String)value);
            }
        }
        ,
        ShippingOptionId {
            public Object get(OrderEOImpl obj) {
                return obj.getShippingOptionId();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setShippingOptionId((Number)value);
            }
        }
        ,
        PaymentOptionId {
            public Object get(OrderEOImpl obj) {
                return obj.getPaymentOptionId();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setPaymentOptionId((Number)value);
            }
        }
        ,
        DiscountId {
            public Object get(OrderEOImpl obj) {
                return obj.getDiscountId();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setDiscountId((Number)value);
            }
        }
        ,
        CouponId {
            public Object get(OrderEOImpl obj) {
                return obj.getCouponId();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setCouponId((Number)value);
            }
        }
        ,
        FreeShippingFlag {
            public Object get(OrderEOImpl obj) {
                return obj.getFreeShippingFlag();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setFreeShippingFlag((String)value);
            }
        }
        ,
        CustomerCollectFlag {
            public Object get(OrderEOImpl obj) {
                return obj.getCustomerCollectFlag();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setCustomerCollectFlag((String)value);
            }
        }
        ,
        CollectionWarehouseId {
            public Object get(OrderEOImpl obj) {
                return obj.getCollectionWarehouseId();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setCollectionWarehouseId((Number)value);
            }
        }
        ,
        GiftwrapFlag {
            public Object get(OrderEOImpl obj) {
                return obj.getGiftwrapFlag();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setGiftwrapFlag((String)value);
            }
        }
        ,
        GiftwrapMessage {
            public Object get(OrderEOImpl obj) {
                return obj.getGiftwrapMessage();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setGiftwrapMessage((String)value);
            }
        }
        ,
        CreatedBy {
            public Object get(OrderEOImpl obj) {
                return obj.getCreatedBy();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setCreatedBy((String)value);
            }
        }
        ,
        CreationDate {
            public Object get(OrderEOImpl obj) {
                return obj.getCreationDate();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setCreationDate((Date)value);
            }
        }
        ,
        LastUpdatedBy {
            public Object get(OrderEOImpl obj) {
                return obj.getLastUpdatedBy();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setLastUpdatedBy((String)value);
            }
        }
        ,
        LastUpdateDate {
            public Object get(OrderEOImpl obj) {
                return obj.getLastUpdateDate();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setLastUpdateDate((Date)value);
            }
        }
        ,
        ObjectVersionId {
            public Object get(OrderEOImpl obj) {
                return obj.getObjectVersionId();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setObjectVersionId((Number)value);
            }
        }
        ,
        OrderItemEO {
            public Object get(OrderEOImpl obj) {
                return obj.getOrderItemEO();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setAttributeInternal(index(), value);
            }
        }
        ,
        PersonEO {
            public Object get(OrderEOImpl obj) {
                return obj.getPersonEO();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setPersonEO((EntityImpl)value);
            }
        }
        ;
        private static AttributesEnum[] vals = null;
        private static int firstIndex = 0;

        public abstract Object get(OrderEOImpl object);

        public abstract void put(OrderEOImpl object, Object value);

        public int index() {
            return AttributesEnum.firstIndex() + ordinal();
        }

        public static int firstIndex() {
            return firstIndex;
        }

        public static int count() {
            return AttributesEnum.firstIndex() + AttributesEnum.staticValues().length;
        }

        public static AttributesEnum[] staticValues() {
            if (vals == null) {
                vals = AttributesEnum.values();
            }
            return vals;
        }
    }


    public static final int ORDERID = AttributesEnum.OrderId.index();
    public static final int ORDERDATE = AttributesEnum.OrderDate.index();
    public static final int ORDERSHIPPEDDATE = AttributesEnum.OrderShippedDate.index();
    public static final int ORDERSTATUSCODE = AttributesEnum.OrderStatusCode.index();
    public static final int ORDERTOTAL = AttributesEnum.OrderTotal.index();
    public static final int CUSTOMERID = AttributesEnum.CustomerId.index();
    public static final int SHIPTONAME = AttributesEnum.ShipToName.index();
    public static final int SHIPTOADDRESSID = AttributesEnum.ShipToAddressId.index();
    public static final int SHIPTOPHONENUMBER = AttributesEnum.ShipToPhoneNumber.index();
    public static final int SHIPPINGOPTIONID = AttributesEnum.ShippingOptionId.index();
    public static final int PAYMENTOPTIONID = AttributesEnum.PaymentOptionId.index();
    public static final int DISCOUNTID = AttributesEnum.DiscountId.index();
    public static final int COUPONID = AttributesEnum.CouponId.index();
    public static final int FREESHIPPINGFLAG = AttributesEnum.FreeShippingFlag.index();
    public static final int CUSTOMERCOLLECTFLAG = AttributesEnum.CustomerCollectFlag.index();
    public static final int COLLECTIONWAREHOUSEID = AttributesEnum.CollectionWarehouseId.index();
    public static final int GIFTWRAPFLAG = AttributesEnum.GiftwrapFlag.index();
    public static final int GIFTWRAPMESSAGE = AttributesEnum.GiftwrapMessage.index();
    public static final int CREATEDBY = AttributesEnum.CreatedBy.index();
    public static final int CREATIONDATE = AttributesEnum.CreationDate.index();
    public static final int LASTUPDATEDBY = AttributesEnum.LastUpdatedBy.index();
    public static final int LASTUPDATEDATE = AttributesEnum.LastUpdateDate.index();
    public static final int OBJECTVERSIONID = AttributesEnum.ObjectVersionId.index();
    public static final int ORDERITEMEO = AttributesEnum.OrderItemEO.index();
    public static final int PERSONEO = AttributesEnum.PersonEO.index();

    /**
     * This is the default constructor (do not remove).
     */
    public OrderEOImpl() {
    }


    /**
     * @return the definition object for this instance class.
     */
    public static synchronized EntityDefImpl getDefinitionObject() {
        if (mDefinitionObject == null) {
            mDefinitionObject = EntityDefImpl.findDefObject("com.estebansm.apercuen.model.entities.OrderEO");
        }
        return mDefinitionObject;
    }

    public void addItemToOrder(Number productId) {
      System.out.println("addItemToOrder - productId:"+productId);
      RowIterator orderItems = getOrderItemEO();
      assert orderItems != null;

      OrderItemEOImpl row = existeItemEnOrden(productId, orderItems);
       if (row!=null) {
          // Si ya existe el item comprado agrega uno mas a la cantidad de compra.
          Number qty = (Number)row.getQuantity();
          qty = qty == null ? new Number(1) : qty.add(1);
          row.setQuantity(qty);
        } else {
         //es la primera compra del item en esta orden.
         ProductoEOImpl productEO =  this.buscarProducto(productId);
         this.agregarProductoAorden(productEO, orderItems);
           try {
            getDBTransaction().validate();
          } catch (TxnValException e) {
              System.out.println(e.getMessage());
          } catch (JboException e) {
            System.out.println(e.getMessage());
          }
        }
    }

    private void agregarProductoAorden(ProductoEOImpl productEO,RowIterator orderItems) {        
            OrderItemEOImpl newItem = (OrderItemEOImpl)orderItems.createRow();
            Number unitPrice = (Number)productEO.getListPrice();
          /*   SequenceImpl ORDER_SEQ = new SequenceImpl("ORDER_SEQ",getDBTransaction());
            newItem.setAttribute("OrderId",ORDER_SEQ.getSequenceNumber()); */
            newItem.setProductId(new Number(productEO.getProductId()));
            newItem.setQuantity(new Number(1));
            newItem.setUnitPrice(unitPrice);
            newItem.setCreatedBy("EstebanC");
            newItem.setCreationDate(new Date());
            newItem.setLastUpdateDate(new Date());  
            newItem.setLastUpdatedBy("updater");
            newItem.setObjectVersionId(new Number(1));
       
    }

    private ProductoEOImpl buscarProducto(Number productId) {
        EntityDefImpl productEODef = EntityDefImpl.findDefObject("com.estebansm.apercuen.model.entities.ProductoEO");
        ProductoEOImpl productEO = (ProductoEOImpl)productEODef.findByPrimaryKey(getDBTransaction(),new Key(new Object[] { productId }));
        return productEO;
    }

    private OrderItemEOImpl existeItemEnOrden(Number productId,RowIterator orderItems) {
        OrderItemEOImpl row=null;
        for (row = (OrderItemEOImpl)orderItems.first(); row != null;row = (OrderItemEOImpl)orderItems.next()) {
          System.out.println("addItemToOrder - row.getProductId():"+row.getProductId());
          if (row.getProductId() != null && row.getProductId().equals(productId)) {
            break;
          }
        }
        return row;
    }
    /**
     * Gets the attribute value for OrderId, using the alias name OrderId.
     * @return the OrderId
     */
    public Number getOrderId() {
        return (Number)getAttributeInternal(ORDERID);
    }

    /**
     * Sets <code>value</code> as the attribute value for OrderId.
     * @param value value to set the OrderId
     */
    public void setOrderId(Number value) {
        setAttributeInternal(ORDERID, value);
    }

    /**
     * Gets the attribute value for OrderDate, using the alias name OrderDate.
     * @return the OrderDate
     */
    public Date getOrderDate() {
        return (Date)getAttributeInternal(ORDERDATE);
    }

    /**
     * Sets <code>value</code> as the attribute value for OrderDate.
     * @param value value to set the OrderDate
     */
    public void setOrderDate(Date value) {
        setAttributeInternal(ORDERDATE, value);
    }

    /**
     * Gets the attribute value for OrderShippedDate, using the alias name OrderShippedDate.
     * @return the OrderShippedDate
     */
    public Date getOrderShippedDate() {
        return (Date)getAttributeInternal(ORDERSHIPPEDDATE);
    }

    /**
     * Sets <code>value</code> as the attribute value for OrderShippedDate.
     * @param value value to set the OrderShippedDate
     */
    public void setOrderShippedDate(Date value) {
        setAttributeInternal(ORDERSHIPPEDDATE, value);
    }

    /**
     * Gets the attribute value for OrderStatusCode, using the alias name OrderStatusCode.
     * @return the OrderStatusCode
     */
    public String getOrderStatusCode() {
        return (String)getAttributeInternal(ORDERSTATUSCODE);
    }

    /**
     * Sets <code>value</code> as the attribute value for OrderStatusCode.
     * @param value value to set the OrderStatusCode
     */
    public void setOrderStatusCode(String value) {
        setAttributeInternal(ORDERSTATUSCODE, value);
    }

    /**
     * Gets the attribute value for OrderTotal, using the alias name OrderTotal.
     * @return the OrderTotal
     */
    public Number getOrderTotal() {
        return (Number)getAttributeInternal(ORDERTOTAL);
    }

    /**
     * Sets <code>value</code> as the attribute value for OrderTotal.
     * @param value value to set the OrderTotal
     */
    public void setOrderTotal(Number value) {
        setAttributeInternal(ORDERTOTAL, value);
    }

    /**
     * Gets the attribute value for CustomerId, using the alias name CustomerId.
     * @return the CustomerId
     */
    public Number getCustomerId() {
        return (Number)getAttributeInternal(CUSTOMERID);
    }

    /**
     * Sets <code>value</code> as the attribute value for CustomerId.
     * @param value value to set the CustomerId
     */
    public void setCustomerId(Number value) {
        setAttributeInternal(CUSTOMERID, value);
    }

    /**
     * Gets the attribute value for ShipToName, using the alias name ShipToName.
     * @return the ShipToName
     */
    public String getShipToName() {
        return (String)getAttributeInternal(SHIPTONAME);
    }

    /**
     * Sets <code>value</code> as the attribute value for ShipToName.
     * @param value value to set the ShipToName
     */
    public void setShipToName(String value) {
        setAttributeInternal(SHIPTONAME, value);
    }

    /**
     * Gets the attribute value for ShipToAddressId, using the alias name ShipToAddressId.
     * @return the ShipToAddressId
     */
    public Number getShipToAddressId() {
        return (Number)getAttributeInternal(SHIPTOADDRESSID);
    }

    /**
     * Sets <code>value</code> as the attribute value for ShipToAddressId.
     * @param value value to set the ShipToAddressId
     */
    public void setShipToAddressId(Number value) {
        setAttributeInternal(SHIPTOADDRESSID, value);
    }

    /**
     * Gets the attribute value for ShipToPhoneNumber, using the alias name ShipToPhoneNumber.
     * @return the ShipToPhoneNumber
     */
    public String getShipToPhoneNumber() {
        return (String)getAttributeInternal(SHIPTOPHONENUMBER);
    }

    /**
     * Sets <code>value</code> as the attribute value for ShipToPhoneNumber.
     * @param value value to set the ShipToPhoneNumber
     */
    public void setShipToPhoneNumber(String value) {
        setAttributeInternal(SHIPTOPHONENUMBER, value);
    }

    /**
     * Gets the attribute value for ShippingOptionId, using the alias name ShippingOptionId.
     * @return the ShippingOptionId
     */
    public Number getShippingOptionId() {
        return (Number)getAttributeInternal(SHIPPINGOPTIONID);
    }

    /**
     * Sets <code>value</code> as the attribute value for ShippingOptionId.
     * @param value value to set the ShippingOptionId
     */
    public void setShippingOptionId(Number value) {
        setAttributeInternal(SHIPPINGOPTIONID, value);
    }

    /**
     * Gets the attribute value for PaymentOptionId, using the alias name PaymentOptionId.
     * @return the PaymentOptionId
     */
    public Number getPaymentOptionId() {
        return (Number)getAttributeInternal(PAYMENTOPTIONID);
    }

    /**
     * Sets <code>value</code> as the attribute value for PaymentOptionId.
     * @param value value to set the PaymentOptionId
     */
    public void setPaymentOptionId(Number value) {
        setAttributeInternal(PAYMENTOPTIONID, value);
    }

    /**
     * Gets the attribute value for DiscountId, using the alias name DiscountId.
     * @return the DiscountId
     */
    public Number getDiscountId() {
        return (Number)getAttributeInternal(DISCOUNTID);
    }

    /**
     * Sets <code>value</code> as the attribute value for DiscountId.
     * @param value value to set the DiscountId
     */
    public void setDiscountId(Number value) {
        setAttributeInternal(DISCOUNTID, value);
    }

    /**
     * Gets the attribute value for CouponId, using the alias name CouponId.
     * @return the CouponId
     */
    public Number getCouponId() {
        return (Number)getAttributeInternal(COUPONID);
    }

    /**
     * Sets <code>value</code> as the attribute value for CouponId.
     * @param value value to set the CouponId
     */
    public void setCouponId(Number value) {
        setAttributeInternal(COUPONID, value);
    }

    /**
     * Gets the attribute value for FreeShippingFlag, using the alias name FreeShippingFlag.
     * @return the FreeShippingFlag
     */
    public String getFreeShippingFlag() {
        return (String)getAttributeInternal(FREESHIPPINGFLAG);
    }

    /**
     * Sets <code>value</code> as the attribute value for FreeShippingFlag.
     * @param value value to set the FreeShippingFlag
     */
    public void setFreeShippingFlag(String value) {
        setAttributeInternal(FREESHIPPINGFLAG, value);
    }

    /**
     * Gets the attribute value for CustomerCollectFlag, using the alias name CustomerCollectFlag.
     * @return the CustomerCollectFlag
     */
    public String getCustomerCollectFlag() {
        return (String)getAttributeInternal(CUSTOMERCOLLECTFLAG);
    }

    /**
     * Sets <code>value</code> as the attribute value for CustomerCollectFlag.
     * @param value value to set the CustomerCollectFlag
     */
    public void setCustomerCollectFlag(String value) {
        setAttributeInternal(CUSTOMERCOLLECTFLAG, value);
    }

    /**
     * Gets the attribute value for CollectionWarehouseId, using the alias name CollectionWarehouseId.
     * @return the CollectionWarehouseId
     */
    public Number getCollectionWarehouseId() {
        return (Number)getAttributeInternal(COLLECTIONWAREHOUSEID);
    }

    /**
     * Sets <code>value</code> as the attribute value for CollectionWarehouseId.
     * @param value value to set the CollectionWarehouseId
     */
    public void setCollectionWarehouseId(Number value) {
        setAttributeInternal(COLLECTIONWAREHOUSEID, value);
    }

    /**
     * Gets the attribute value for GiftwrapFlag, using the alias name GiftwrapFlag.
     * @return the GiftwrapFlag
     */
    public String getGiftwrapFlag() {
        return (String)getAttributeInternal(GIFTWRAPFLAG);
    }

    /**
     * Sets <code>value</code> as the attribute value for GiftwrapFlag.
     * @param value value to set the GiftwrapFlag
     */
    public void setGiftwrapFlag(String value) {
        setAttributeInternal(GIFTWRAPFLAG, value);
    }

    /**
     * Gets the attribute value for GiftwrapMessage, using the alias name GiftwrapMessage.
     * @return the GiftwrapMessage
     */
    public String getGiftwrapMessage() {
        return (String)getAttributeInternal(GIFTWRAPMESSAGE);
    }

    /**
     * Sets <code>value</code> as the attribute value for GiftwrapMessage.
     * @param value value to set the GiftwrapMessage
     */
    public void setGiftwrapMessage(String value) {
        setAttributeInternal(GIFTWRAPMESSAGE, value);
    }

    /**
     * Gets the attribute value for CreatedBy, using the alias name CreatedBy.
     * @return the CreatedBy
     */
    public String getCreatedBy() {
        return (String)getAttributeInternal(CREATEDBY);
    }

    /**
     * Sets <code>value</code> as the attribute value for CreatedBy.
     * @param value value to set the CreatedBy
     */
    public void setCreatedBy(String value) {
        setAttributeInternal(CREATEDBY, value);
    }

    /**
     * Gets the attribute value for CreationDate, using the alias name CreationDate.
     * @return the CreationDate
     */
    public Date getCreationDate() {
        return (Date)getAttributeInternal(CREATIONDATE);
    }

    /**
     * Sets <code>value</code> as the attribute value for CreationDate.
     * @param value value to set the CreationDate
     */
    public void setCreationDate(Date value) {
        setAttributeInternal(CREATIONDATE, value);
    }

    /**
     * Gets the attribute value for LastUpdatedBy, using the alias name LastUpdatedBy.
     * @return the LastUpdatedBy
     */
    public String getLastUpdatedBy() {
        return (String)getAttributeInternal(LASTUPDATEDBY);
    }

    /**
     * Sets <code>value</code> as the attribute value for LastUpdatedBy.
     * @param value value to set the LastUpdatedBy
     */
    public void setLastUpdatedBy(String value) {
        setAttributeInternal(LASTUPDATEDBY, value);
    }

    /**
     * Gets the attribute value for LastUpdateDate, using the alias name LastUpdateDate.
     * @return the LastUpdateDate
     */
    public Date getLastUpdateDate() {
        return (Date)getAttributeInternal(LASTUPDATEDATE);
    }

    /**
     * Sets <code>value</code> as the attribute value for LastUpdateDate.
     * @param value value to set the LastUpdateDate
     */
    public void setLastUpdateDate(Date value) {
        setAttributeInternal(LASTUPDATEDATE, value);
    }

    /**
     * Gets the attribute value for ObjectVersionId, using the alias name ObjectVersionId.
     * @return the ObjectVersionId
     */
    public Number getObjectVersionId() {
        return (Number)getAttributeInternal(OBJECTVERSIONID);
    }

    /**
     * Sets <code>value</code> as the attribute value for ObjectVersionId.
     * @param value value to set the ObjectVersionId
     */
    public void setObjectVersionId(Number value) {
        setAttributeInternal(OBJECTVERSIONID, value);
    }

    /**
     * getAttrInvokeAccessor: generated method. Do not modify.
     * @param index the index identifying the attribute
     * @param attrDef the attribute

     * @return the attribute value
     * @throws Exception
     */
    protected Object getAttrInvokeAccessor(int index,
                                           AttributeDefImpl attrDef) throws Exception {
        if ((index >= AttributesEnum.firstIndex()) && (index < AttributesEnum.count())) {
            return AttributesEnum.staticValues()[index - AttributesEnum.firstIndex()].get(this);
        }
        return super.getAttrInvokeAccessor(index, attrDef);
    }

    /**
     * setAttrInvokeAccessor: generated method. Do not modify.
     * @param index the index identifying the attribute
     * @param value the value to assign to the attribute
     * @param attrDef the attribute

     * @throws Exception
     */
    protected void setAttrInvokeAccessor(int index, Object value,
                                         AttributeDefImpl attrDef) throws Exception {
        if ((index >= AttributesEnum.firstIndex()) && (index < AttributesEnum.count())) {
            AttributesEnum.staticValues()[index - AttributesEnum.firstIndex()].put(this, value);
            return;
        }
        super.setAttrInvokeAccessor(index, value, attrDef);
    }

    /**
     * @return the associated entity oracle.jbo.RowIterator.
     */
    public RowIterator getOrderItemEO() {
        return (RowIterator)getAttributeInternal(ORDERITEMEO);
    }

    /**
     * @return the associated entity oracle.jbo.server.EntityImpl.
     */
    public EntityImpl getPersonEO() {
        return (EntityImpl)getAttributeInternal(PERSONEO);
    }

    /**
     * Sets <code>value</code> as the associated entity oracle.jbo.server.EntityImpl.
     */
    public void setPersonEO(EntityImpl value) {
        setAttributeInternal(PERSONEO, value);
    }

    /**
     * @param orderId key constituent

     * @return a Key object based on given key constituents.
     */
    public static Key createPrimaryKey(Number orderId) {
        return new Key(new Object[]{orderId});
    }


}
